﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Settings;

namespace djs_mp3_manager.Nastroje.MoznostiTabs
{
    public partial class Enviroment : UserControl,ISettingable<Enviroment.TypesForChange>
    {
        public Enviroment()
        {
            InitializeComponent();
        }

        public enum TypesForChange
        {
            LanguageFile
        }

        private string languageFilePath = null;
        private static List<TypesForChange> changed = new List<TypesForChange>();

        public event OnChangeDelegate OnChangeEvent;

        public TypesForChange AddNameOfChanged
        {
            set
            {
                if (!changed.Contains(value))
                {
                    changed.Add(value);
                }
                if (OnChangeEvent != null)
                {
                    OnChangeEvent();
                }
            }
        }

        public string LangFile
        {
            get
            {
                return this.languageFilePath;
            }
        }

        public List<TypesForChange> ListOfChanged
        {
            get
            {
                return changed;
            }
        }

        public void RemoveChanged()
        {
            changed.Clear();
        }

        private void buttonOpenLanguageFile_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter = "XML files (*.xml)|*.xml";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileInfo fi = new FileInfo(openFileDialog.FileName);
                languageFile.Text = fi.Name;
                languageFilePath = fi.FullName;
                AddNameOfChanged = TypesForChange.LanguageFile;
            }
        }

        private void Enviroment_Load(object sender, EventArgs e)
        {
            //changed = new List<TypesForChange>();
            languageFilePath = Setting.Enviroment.Lang;
            languageFile.Text = new FileInfo(languageFilePath).Name;
        }

    }
}
